import java.util.Arrays;

public class HighCard {
  public int cheat(int[] mine, int[] friend) {
    
    if (mine.length != friend.length)
      return -1;
    int[] mine_copy = mine;
    int[] friend_copy = friend;
    Arrays.sort(mine_copy);
    Arrays.sort(friend_copy);
    
    int mine_index = 0;
    int friend_index = 0;
    int count = 0;
    
    //while loop here is beautiful, need to chech every number whether it could contribue.
    while (mine_index <= (mine_copy.length-1)) {
      
      if(mine_copy[mine_index] <= friend_copy[friend_index]) {
        mine_index++;
      }
      else if(mine_copy[mine_index] > friend_copy[friend_index]) {
        count++;
        mine_index++;
        friend_index++;
      }
      }
    }
    
    return count;
  }
}